﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="list.aspx.cs" Inherits="background.Manager.Enterprise.Message.list" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>评论管理</title>
    <link href="../../Styles/index.css" rel="stylesheet" />
    <script src="../../Scripts/jquery-1.8.2.min.js"></script>
    <script src="../../Scripts/layer/layer.js"></script>

    <script type="text/javascript">
        function SetState(obj) {
            $.post("Action/msg.ashx", { action: "changeOrder", order: $(obj).val(), id: $(obj).attr("data-id") }, function (ret) {
                if (!ret) {
                    layer.msg("排序保存失败");
                }
            })
        }
        function massState() {
            var d = new Array();
            $("input[name='idbox']:checked").each(function () { d.push($(this).val()); })
            if (d.length == 0) { layer.msg("请选择要审核的项"); return; }

            layer.confirm('设置要审核的状态', {
                btn: ['通过', '禁用'] //按钮
            }, function () {
                $.post("Action/msg.ashx", { action: "massState", state: 1, idList: d.join(',') }, function (ret) {
                    if (ret) {
                        layer.msg("通过设置成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起通过设置失败，稍后再试", { icon: 2 });
                    }
                })
            }, function () {
                $.post("Action/msg.ashx", { action: "massState", state: 0, idList: d.join(',') }, function (ret) {
                    if (ret) {
                        layer.msg("禁用设置成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起禁用设置失败，稍后再试", { icon: 2 });
                    }
                })
            });
        }
        function massDelete() {
            var d = new Array();
            $("input[name='idbox']:checked").each(function () { d.push($(this).val()); })
            if (d.length == 0) { layer.msg("请选择要删除的项"); return; }
            if (confirm("确定要删除所选项吗？")) {
                $.post("Action/msg.ashx", { action: "delete", idList: d.join(',') }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function deletes(id) {
            if (confirm("确定要删除吗？")) {
                $.post("Action/msg.ashx", { action: "delete", idList: id }, function (ret) {
                    if (ret) {
                        layer.msg("删除成功，2秒后自动刷新页面", { icon: 1, time: 2000 }, function () { window.location.reload(); });
                    } else {
                        layer.msg("对不起删除失败，稍后再试", { icon: 2 });
                    }
                })
            }
        }
        function checkboxAll(obj) {
            $("input[name='idbox']").attr("checked", $(obj).is(":checked"));
        }
        function SetContent(_content, _id,_setType) {
            $.post("Action/msg.ashx", { action: "Manager", setType: _setType, Content: _content, id: _id }, function (ret) {
                if (!ret) {
                    layer.msg("对不起保存失败，稍后再试", { icon: 2 });
                }
            })
        }
    </script>
</head>
<body>
    <div class="top">
        <strong>评论管理</strong>
        <span style="float: right"><a href="javascript:history.back();">
            <img src="../../Images/bak.png" />后退</a></span>
    </div>
    <div class="main">
        <div>
            <div class="tool_search">
                <input type="button" class="sbtn" value="批量审核" onclick="massState()" />&nbsp;&nbsp;<input type="button" class="sbtn" value="批量删除" onclick="    massDelete()" />
                &nbsp;<span style="color:green">提示：1.可直接修改评论内容；2.直接在回复内容框中回复即可.</span>
            </div>
            <table border="0" cellpadding="0" cellspacing="0" class="listtable">
                <tr>
                    <th class="th" style="width: 20px">
                        <input type="checkbox" onchange="checkboxAll(this)" /></th>
                    <th class="th">用户</th>
                    <th class="th">网址</th>
                    <th class="th">评论内容</th>
                    <th class="th">回复内容</th>
                    <th class="th">状态</th>
                    <th class="th thlast">操作</th>
                </tr>
                <%System.Data.DataTable dt= Codes.Message.getList(Request["KEY"], int.Parse(string.IsNullOrEmpty(Request["p"])?"1":Request["p"]), 20); %>
                <%foreach(System.Data.DataRow dr in dt.Rows) {%>
                <tr>
                    <td class="td">
                        <input type="checkbox" name="idbox" value="<%=dr["id"] %>" /></td>
                    <td class="td"><%=dr["UserName"] %></td>
                    <td class="td" style="line-height: 20px;"><div style="word-wrap:break-word;width:220px;"><a href="<%=dr["SourceUrl"] %>" target="_blank"><%=dr["SourceUrl"] %></a></div></td>
                    <td class="td" style="line-height: 20px;">评论日期：<%=Codes.h.ManuTime(((DateTime)dr["addtime"]).ToString("yyyy/MM/dd HH:mm")) %>
                        <br />
                        <textarea style="height:40px;width:250px;" onchange="SetContent(this.value,<%=dr["ID"]%>,'c')"><%=dr["Content"] %></textarea>
                    </td>
                    <td class="td" style="line-height: 20px;">
                        <%=string.IsNullOrEmpty(dr["ReplyAddTime"].ToString())?"<span style='color:#999'>未回复</font>":"回复日期："+Codes.h.ManuTime(((DateTime)dr["ReplyAddTime"]).ToString("yyyy/MM/dd HH:mm")) %>
                        <br />
                        <textarea style="height:40px;width:250px;" onchange="SetContent(this.value,<%=dr["ID"]%>,'r')"><%=dr["ReplyContent"] %></textarea>
                    </td>
                    <td class="td"><%=(bool)dr["State"]?"显示中":"禁用中" %></td>
                    <td class="td tdlast txtcenter">                        
                        <a href="javascript:void(0);" onclick="deletes(<%=dr["id"] %>)">
                            <img src="../../Images/delete.png" class="tool_delete" />删除</a></td>
                </tr>
                <%} %>
            </table>
            <div class="tcdPageCode"></div>
            <script src="../../Scripts/jquery.page.js"></script>
            <script>
                $(".tcdPageCode").createPage({
                    pageCount: '<%=Math.Ceiling((double)Codes.Message.getListCount(Request["KEY"])/20)%>',
                    current: '<%=string.IsNullOrEmpty(Request["p"])?"1":Request["p"]%>',
                    backFn: function (p) {
                        window.location.href = "?p=" + p;
                    }
                });
            </script>
        </div>
    </div>
    <!--#include file='../../Include/footer.html'-->
</body>
</html>
